package com.example.springboot.ytest.ytest;

import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang.StringUtils;

public class StringTest {
	
	public static void formatTest() {
		String s = String.format("上浮%d%%", 10L);
		System.out.println(s);
	}
	
	// 数组的拼接
	public static void splicing() {
		List<String> cities = Arrays.asList("Milan", 
                "London", 
                "New York", 
                "San Francisco");
		String citiesCommaSeparated = String.join(",", cities);
		System.out.println(citiesCommaSeparated);
	}
	
	static void split(){
		final String ss = "a,b,,,,2,";
		String [] arrayUtil = StringUtils.split(ss, ","); // 这个会删除空的值 
		String [] array = ss.split(","); // 这个会把空的都算出来，
		System.out.println("len: "+array.length);
		for(String s: array){
			System.out.println(s);
		}
		
		System.out.println("lenUtil: "+arrayUtil.length);
		for(String s: arrayUtil){
			System.out.println(s);
		}
	}
	
	public static void main(String[] args) {
//		formatTest();
//		splicing();
		split();
	}
}
